<?php

	namespace app\admin\behavior;

	use app\admin\model\crmeb\SystemAdmin;
	use think\Cookie;
	use think\Session;

	class Admin{
		public function adminAddAfter($admin){
			$data = [
				'id' =>$admin['id'],
				'account' => $admin['username'],
				'pwd' => '',
				'real_name' => $admin['nickname'],
				'roles' => 2,
				'status' => 1,
				'level' => 1,
			];
			SystemAdmin::create($data);
		}

		public function adminLoginAfterCrmeb(){
			$admin = Session::get('admin');
			Cookie::set('id', $admin['id'], ['prefix'=>'wenxin_admin_','path'=>'/','domain'=>config('admin.top_domain'),'secure'=>true]);
		}

		public function adminLogoutAfter($admin){
			Cookie::delete('id', 'wenxin_admin_');
		}
	}